// pages/cut/component/upload/upload.js
import {uploadFile} from '../../../../utils/request'
Component({

  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    addVideo(){
      wx.chooseMedia({
        count: 1,
        success:(res)=>{
          const uri = res.tempFiles[0].tempFilePath
          wx.showLoading({
            title: '上传中',
            mask: true
          })
          uploadFile({
            filePath: uri
          }).then(res => {
            this.triggerEvent("upload",{uri:res.data})
            wx.hideLoading()
          })

          this.setData({
            videoSrc: uri
          })

          wx.getVideoInfo({
            src: uri,
            success:(res)=>{
              // console.log('videoInfo=====>',res)
              this.setData({
                duration: res.duration
              })
            }
          })
  
          // this.videoCtx = wx.createVideoContext('video');
          // this.canvasCtx = wx.createCanvasContext('myCanvas');
      
        }
      })
    },
  }
})